package com.pro.controller;

import com.pro.pojo.*;
import com.pro.service.JsStatisticalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 * @author YuQing
 * @date 2022/1/8 17:22
 */
@Controller
@RequestMapping(value = "JsStatistical")
public class JsStatisticalController {
    @Autowired
    private JsStatisticalService jsStatisticalService;

    //商品点击量
    @RequestMapping(value = "/getProductCategroys")
    @ResponseBody
    public JsonData getSyProductCategroys(){
        List<JsProductCategroy> syProductCategroys = jsStatisticalService.getProductCategroys();
        return syProductCategroys != null ? JsonData.buildSuccess(syProductCategroys) : JsonData.buildError("服务器出错了");
    }
    //商品收藏量
    @RequestMapping(value = "/getProductCategroysColl")
    @ResponseBody
    public JsonData getSyProductCategroysColl(){
        List<JsProductCategroy> syProductCategroys = jsStatisticalService.getProductCategroysColl(3);
        return syProductCategroys != null ? JsonData.buildSuccess(syProductCategroys) : JsonData.buildError("服务器出错了");
    }
    //课程点赞量
    @RequestMapping(value = "/getCourseClass")
    @ResponseBody
    public JsonData getCourseClass(){
        List<JsCourseClass> courseClass = jsStatisticalService.getCourseClass();
        return courseClass != null ? JsonData.buildSuccess(courseClass) : JsonData.buildError("服务器出错了");
    }

    //课程分享量
    @RequestMapping(value = "/getCourseClassShare")
    @ResponseBody
    public JsonData getCourseClassShare(){
        List<JsCourseClass> courseClass = jsStatisticalService.getCourseClassShare();
        return courseClass != null ? JsonData.buildSuccess(courseClass) : JsonData.buildError("服务器出错了");
    }

    //课程收藏量
    @RequestMapping(value = "/getCourseClassColl")
    @ResponseBody
    public JsonData getCourseClassColl(){
        List<JsCourseClass> courseClass = jsStatisticalService.getCourseClassColl();
        return courseClass != null ? JsonData.buildSuccess(courseClass) : JsonData.buildError("服务器出错了");
    }

    //课程预览量
    @RequestMapping(value = "/getCourseClassLook")
    @ResponseBody
    public JsonData getCourseClassLook(){
        List<JsCourseClass> courseClass = jsStatisticalService.getCourseClassLook();
        return courseClass != null ? JsonData.buildSuccess(courseClass) : JsonData.buildError("服务器出错了");
    }
    //微圈点赞量
    @RequestMapping(value = "/getMicrocircle")
    @ResponseBody
    public JsonData getMicrocircle(){
        List<JsActicleCategroy> microcircles = jsStatisticalService.getMicrocircle();
        return microcircles != null ? JsonData.buildSuccess(microcircles) : JsonData.buildError("服务器出错了");
    }
    //微圈分享量
    @RequestMapping(value = "/getMicrocircleShare")
    @ResponseBody
    public JsonData getMicrocircleShare(){
        List<JsActicleCategroy> microcircles = jsStatisticalService.getMicrocircleShare();
        return microcircles != null ? JsonData.buildSuccess(microcircles) : JsonData.buildError("服务器出错了");
    }
    //微圈收藏量
    @RequestMapping(value = "/getMicrocircleColl")
    @ResponseBody
    public JsonData getMicrocircleColl(){
        List<JsActicleCategroy> microcircles = jsStatisticalService.getMicrocircleColl(4);
        return microcircles != null ? JsonData.buildSuccess(microcircles) : JsonData.buildError("服务器出错了");
    }
    //微圈点击量
    @RequestMapping(value = "/getMicrocircleLook")
    @ResponseBody
    public JsonData getMicrocircleLook(){
        List<JsActicleCategroy> microcircles = jsStatisticalService.getMicrocircleLook();
        return microcircles != null ? JsonData.buildSuccess(microcircles) : JsonData.buildError("服务器出错了");
    }
    //关键字搜索量
    @RequestMapping(value = "/getSearchKeyWords")
    @ResponseBody
    public JsonData getSearchKeyWords(){
        List<JsSearchKeywords> keyWords = jsStatisticalService.getSearchKeyWords();
        return keyWords != null ? JsonData.buildSuccess(keyWords) : JsonData.buildError("服务器出错了");
    }
    //人员统计
    @RequestMapping(value = "/getUser")
    @ResponseBody
    public JsonData getUser(){
        Integer beforeUser = jsStatisticalService.getBeforeUser();
        Integer backstageUser = jsStatisticalService.getBackstageUser();
        List list = new ArrayList();
        list.add(beforeUser);
        list.add(backstageUser);
        return list != null ? JsonData.buildSuccess(list) : JsonData.buildError("服务器出错了");
    }
    //课程订单
    @RequestMapping(value = "/getCourseOrder")
    @ResponseBody
    public JsonData getCourseOrder(){
        List<JsCourse> courseOrder = jsStatisticalService.getCourseOrder(2);
        return courseOrder != null ? JsonData.buildSuccess(courseOrder) : JsonData.buildError("服务器出错了");
    }
    //商品订单
    @RequestMapping(value = "/getProductOrder")
    @ResponseBody
    public JsonData getProductOrder(){
        List<JsProduct> productOrder = jsStatisticalService.getProductOrder(3);
        return productOrder != null ? JsonData.buildSuccess(productOrder) : JsonData.buildError("服务器出错了");
    }
    //查询课程评论
    @RequestMapping(value = "/getCourseComment")
    @ResponseBody
    public JsonData getCourseComment(){
        List<JsComment> courseComment = jsStatisticalService.getCourseComment(2);
        return courseComment != null ? JsonData.buildSuccess(courseComment) : JsonData.buildError("服务器出错了");
    }
    //查询商品评论
    @RequestMapping(value = "/getProductComment")
    @ResponseBody
    public JsonData getProductComment(){
        List<JsComment> productComment = jsStatisticalService.getProductComment(3);
        return productComment != null ? JsonData.buildSuccess(productComment) : JsonData.buildError("服务器出错了");
    }
    //查询微圈评论
    @RequestMapping(value = "/getMicrocircleComment")
    @ResponseBody
    public JsonData getMicrocircleComment(){
        List<JsComment> microcircleComment = jsStatisticalService.getMicrocircleComment(4);
        return microcircleComment != null ? JsonData.buildSuccess(microcircleComment) : JsonData.buildError("服务器出错了");
    }

}
